package services;


import java.util.ArrayList;

import fr.obeo.acceleo.gen.template.eval.ENodeCastException;

public class ListServices {
	
	private ArrayList<String> lista = new ArrayList<String>();
	
	/**
	 * Agrega una cadena a la lista y verifica que sea única.
	 * 
	 * @param s
	 * @throws ENodeCastException
	 */
	public void add(String s) throws ENodeCastException {
		if (!lista.contains(s)) {
			lista.add(s);
		}
	}
	
	public String getElementos(String x) throws ENodeCastException {
		StringBuilder sb = new StringBuilder();
		for (String s : lista) {
			sb.append("import ").append(s).append(';').append('\n');
		}
		if (sb.length() > 0) {
			sb.deleteCharAt(sb.length()-1);
		}
		return sb.toString();
	}
}
